package com.sxc.response;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 响应数据
 */
@WebServlet("/s01")
public class Servlet01 extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取字符输出流
        PrintWriter writer = resp.getWriter();
        // 输出数据
        writer.write("Hello");

        //字节输出流
        ServletOutputStream outputStream = resp.getOutputStream();
        outputStream.write("Hi".getBytes());
    }
}
